package model.dap.dao;
import model.dap.domain.Deal;
import model.dap.domain.OrderDeal;
import model.dap.mapper.DealMapper;
import model.dap.mapper.OrderDealMapper;

import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;

import common.base.DaoConfig;

public class OrderDealDAO implements OrderDealMapper {
	SqlSession session = DaoConfig.getSqlSessionFactory().openSession();
	Logger log = Logger.getLogger(OrderDealDAO.class);
	@Override
	public int insertOrder(OrderDeal mastOrder) {
		// TODO Auto-generated method stub
		try {
			return session.getMapper(OrderDealMapper.class).insertOrder(mastOrder);
		} catch (Exception e) {
			log.error(e.getMessage());
			session.rollback();
		} finally {
			session.commit();
			session.close();
		}
		return 0;
	}
	@Override
	public int updateDeal(OrderDeal masrDeal) {
		// TODO Auto-generated method stub
		try {
			return session.getMapper(OrderDealMapper.class).updateDeal(masrDeal);
		} catch (Exception e) {
			log.error(e.getMessage());
			session.rollback();
		} finally {
			session.commit();
			session.close();
		}
		return 0;
	}
	
	@Override
	public int updateDealStatus3O(OrderDeal deal) {
		
		// TODO Auto-generated method stub
		try {
			return session.getMapper(OrderDealMapper.class).updateDealStatus3O(deal);
		} catch (Exception e){
			log.error(e.getMessage());
			session.rollback();
		} finally {
			session.commit();
			session.close();
		}
		return 0;
	}

}
